package example.com.terry.servlet;

import example.com.terry.utils.JDBCUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/deleteUser")
public class DeleteUser extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");

        String sql = "delete from tb_user where id = '" + id + "'";
        boolean init = JDBCUtils.init(sql);
        if (init) {
            resp.getWriter().println("删除成功");
        } else {
            resp.getWriter().println("删除失败");
        }
    }
}
